From: Robert Lipe Date: Sat, 31 Dec 2016 23:28:10 +0000 (-0600) Subject: See if I can make QtWebKit (Linux) and QtWebEngine (everywhere else) coexist. X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~9^2~3 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=25e9f486c3ec1b143b1676ef10123c1ebad18473;p=gpsbabel.git See if I can make QtWebKit (Linux) and QtWebEngine (everywhere else) coexist. --- diff --git a/gui/app.pro b/gui/app.pro index 930cfe0f7..c5125072c 100755 --- a/gui/app.pro +++ b/gui/app.pro @@ -15,11 +15,12 @@ QT += core \ gui \ network \ xml \ - webkit -greaterThan(QT_MAJOR_VERSION, 4) { - QT += widgets \ - webkitwidgets +greaterThan(QT_MINOR_VERSION, 5) { + QT += webenginewidgets + DEFINES += HAVE_WEBENGINE +} else { + QT += webkit webkitwidgets } unix:DESTDIR = objects diff --git a/gui/map.cc b/gui/map.cc index 32843764a..23cee4d70 100644 --- a/gui/map.cc +++ b/gui/map.cc @@ -20,17 +20,23 @@ // USA // //------------------------------------------------------------------------ +#include "map.h" + #include #include #include +#if HAVE_WEBENGINE +#include +#include +#else #include #include +#endif #include #include #include #include -#include "map.h" #include "appname.h" #include "dpencode.h" @@ -47,7 +53,11 @@ static QString stripDoubleQuotes(const QString s) { //------------------------------------------------------------------------ Map::Map(QWidget *parent, const Gpx &gpx, QPlainTextEdit *te): +#if HAVE_WEBENGINE + QWebEngineView(parent), +#else QWebView(parent), +#endif gpx_(gpx), mapPresent_(false), busyCursor_(false), @@ -125,7 +135,14 @@ static QString fmtLatLng(const LatLng &l) { void Map::showGpxData() { MarkerClicker *mclicker = new MarkerClicker(this); +#if HAVE_WEBENGINE + QWebChannel* channel = new QWebChannel(this); + this->page()->setWebChannel(channel); + channel->registerObject(QStringLiteral("mclicker"), mclicker); +// this->addToJavaScriptWindowObject("mclicker", mclicker); +#else this->page()->mainFrame()->addToJavaScriptWindowObject("mclicker", mclicker); +#endif connect(mclicker, SIGNAL(markerClicked(int, int )), this, SLOT(markerClicked(int, int))); connect(mclicker, SIGNAL(logTime(const QString &)), this, SLOT(logTimeX(const QString &))); @@ -385,7 +402,11 @@ void Map::panTo(const LatLng &loc) //------------------------------------------------------------------------ void Map::resizeEvent ( QResizeEvent * ev) { +#if HAVE_WEBENGINE + QWebEngineView::resizeEvent(ev); +#else QWebView::resizeEvent(ev); +#endif if (mapPresent_) evaluateJS(QString("map.checkResize();")); } @@ -429,7 +450,11 @@ void Map::frameRoute(int i) //------------------------------------------------------------------------ void Map::evaluateJS(const QString &s, bool upd) { +#if HAVE_WEBENGINE + this->page()->runJavaScript(s); +#else this->page()->mainFrame()->evaluateJavaScript(s); +#endif if (upd) { this->update(); } diff --git a/gui/map.h b/gui/map.h index e729a1fd2..baa57e915 100644 --- a/gui/map.h +++ b/gui/map.h @@ -22,8 +22,11 @@ //------------------------------------------------------------------------ #ifndef MAP_H #define MAP_H - +#if HAVE_WEBENGINE +#include +#else #include +#endif #include #include #include "gpx.h" @@ -49,7 +52,11 @@ signals: +#if HAVE_WEBENGINE +class Map : public QWebEngineView +#else class Map : public QWebView +#endif { Q_OBJECT public: